Skip to content

fix(cli): launch connect via localhost when server binds 0.0.0.0 - #1219

Merged
jundot merged 2 commits into
jundot:mainfrom
fish0710:fix/launch-connect-0.0.0.0
May 13, 2026
Merged

jundot merged 2 commits into
jundot:mainfrom
fish0710:fix/launch-connect-0.0.0.0

Conversation

@fish0710

Copy link
Copy Markdown
Contributor

Summary

Fixes omlx launch failing when the server is configured to bind to 0.0.0.0.

Problem

When settings.json contains host: "0.0.0.0" (e.g. after omlx serve --host 0.0.0.0), omlx launch claude fails with:

oMLX server is not running at http://0.0.0.0:12345
Start the server first: omlx serve

0.0.0.0 is a valid bind-all address but not a valid client-side connect address.

Fix

Introduce connect_host in launch_command() which falls back to 127.0.0.1 whenever the resolved host is 0.0.0.0 (or empty). The original host value is preserved for display; only the actual HTTP connection URL and the downstream integration launch() call use the corrected address.

Test plan

  • omlx serve --host 0.0.0.0 --port 12345 then omlx launch claude → connects successfully
  • omlx serve --host 127.0.0.1 then omlx launch claude → still works (no regression)

🤖 Generated with Claude Code

egead834-cell and others added 2 commits May 13, 2026 10:04
…odel loads

The global `_MTP_ACTIVE` flag (set via `set_mtp_active` before `mlx_lm.load()`)
persists after model load completes. This caused three failure modes:

1. **Model switch**: Loading a non-MTP-compatible model after an MTP-enabled one
   left `_MTP_ACTIVE=True`. The patched `Model.__init__` on the new model then
   incorrectly attached an MTP head, crashing with missing mtp.* weights.

2. **SpecPrefill draft model (BatchedEngine)**: A target model with MTP enabled
   leaked the flag to the draft model load, causing the same crash.

3. **SpecPrefill draft model (VLMBatchedEngine)**: Same as (2) for VLM path.

Changes:
- `maybe_apply_pre_load_patches()`: reset `_MTP_ACTIVE=False` at function entry
  before any model-specific logic, so every load starts from a known state.
- `BatchedEngine._load_draft()`: snapshot current flag, disable MTP, load draft,
  restore flag.
- `VLMBatchedEngine._load_draft()`: same snapshot/restore guard.

Closes the root cause behind "Native MTP is enabled for this model but the
converted weights are missing the mtp.* tensors" errors when using SpecPrefill
with a Qwen3.5 draft after an MTP-enabled model was previously loaded.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
0.0.0.0 is a valid bind-all address but cannot be used as a connect
address from the client side. When settings.json contains host=0.0.0.0
(e.g. after starting the server with --host 0.0.0.0), `omlx launch`
fails with "oMLX server is not running at http://0.0.0.0:12345".

Introduce `connect_host` which falls back to 127.0.0.1 whenever the
resolved host is 0.0.0.0 (or empty), while keeping the original host
value for display purposes. This also fixes downstream integrations
(claude, codex, pi, etc.) which receive the host via launch().

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@jundot

jundot commented May 13, 2026

Copy link
Copy Markdown
Owner

Thanks for catching this. The 0.0.0.0 to 127.0.0.1 fallback in launch_command is the right shape; the bind addr vs connect addr distinction matches what utils/network.py already does. Noticed the branch also carries the _MTP_ACTIVE leak fix (afe0bb2); the root cause analysis there is spot on, especially the draft-model path that bypasses maybe_apply_pre_load_patches.

Merging.

@jundot
jundot merged commit 04a0ce6 into jundot:main May 13, 2026
jundot added a commit that referenced this pull request Jul 28, 2026
Port the text-model implementation from mlx-lm PR #1219, with
oMLX runtime registration, model routing, and oQ integration.

Source: ml-explore/mlx-lm#1219
Upstream-Commit: 96dd6fc2e0d2a1c43fcbd5b3c4be7dee640ad304
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants